/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejercicios6_1;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Mañana
 */
public class Employee implements Serializable {

    /**
     * @param args the command line arguments
     */
    private static final long serialVersionUID = 5L;
    private int emp_no;
    private String lastname;
    private String name;
    private int job;
    private Date date;
    private double salary;
    private double commission;
    private int dept_number;

    Employee(int emp_no, String lastname, String name, int job, String sDate,
            double salary, double commission, int dept_number) {
        Date date;

        emp_no = this.emp_no;
        if (lastname.length() > 10) {
            lastname = this.lastname.substring(0, 10);
        } else {
            this.lastname = lastname;
        }

        if (name.length() > 10) {
            name = this.name.substring(0, 10);
        } else {
            this.name = name;
        }

        this.job = job;

        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yy");
        try {
            date = formatter.parse(sDate);
        } catch (ParseException e) {
            date = null;
        }
        this.date = date;
        this.salary = salary;
        this.commission = commission;
        this.dept_number = dept_number;

    }

    public int getEmp_no() {
        return emp_no;
    }

    public void setEmp_no(int emp_no) {
        this.emp_no = emp_no;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {

        if (lastname.length() > 10) {
            lastname = this.lastname.substring(0, 10);
        } else {
            this.lastname = lastname;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name.length() > 10) {
            name = this.name.substring(0, 10);
        } else {
            this.name = name;
        }
    }

    public int getJob() {
        return job;
    }

    public void setJob(int job) {
        this.job = job;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(String sDate) {
        Date date;
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy");
        try {
            date = formatter.parse(sDate);
        } catch (ParseException e) {
            date = null;
        }
        this.date = date;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getCommission() {
        return commission;
    }

    public void setCommission(double commission) {
        this.commission = commission;
    }

    public int getDept_number() {
        return dept_number;
    }

    public void setDept_number(int dept_number) {
        this.dept_number = dept_number;
    }
}
